package com.shelpe.services.sinbad.repository.jpa;

import java.math.BigInteger;
import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import com.shelpe.services.sinbad.entity.jpa.AdgroupLimit;

public interface AdgroupLimitRepository extends PagingAndSortingRepository<AdgroupLimit, Long> {

	AdgroupLimit findByAdgroupID(long adgroupID);
	
	AdgroupLimit findByAdgroupIDAndStatus(long adgroupID,AdgroupLimit.Status status);

	@Transactional
	@Modifying
	@Query(value = "select ad.adgroup_id from adgroups ad where `limit` > 0 and drive_type in (1,2,4) and online_status = 'online' and create_time > ?", nativeQuery = true)
	List<BigInteger> findInserviceNick(Date dateTime);
}
